package edu.msu.scrabble.project1;

import android.os.Bundle;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;

public class ColorSelectActivity extends GlobalMenuActivity {

	public static final String COLOR = "COLOR";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_color_select);
	}

	public void selectColor(int color) {
		thecloud.setNotLeavingApp(true);
		Intent result = new Intent();
		result.putExtra(COLOR, color);
		setResult(Activity.RESULT_OK, result);
		finish();
    }
	/**
	 * Make sure our session is set up, bounce to log in otherwise
	 */
	@Override
	protected void onResume() {
		super.onResume();

		if(!thecloud.loggedIn()) {
			thecloud.setNotLeavingApp(true);
			Toast.makeText(this, R.string.text_not_loggedin, Toast.LENGTH_SHORT).show();
			Intent intent = new Intent(this, LogInActivity.class);
			intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			startActivity(intent);
		}
	}
}
